package cn.gailvlun.gll.presentation.emotion.drawer

import android.databinding.ObservableBoolean
import android.databinding.ObservableField
import android.view.View
import cn.gailvlun.gll.R
import cn.gailvlun.gll.net.base.Profile
import cn.gailvlun.gll.net.emotion.Emotion
import cn.gailvlun.gll.net.emotion.Heart
import cn.gailvlun.gll.presentation.base.BaseActivity
import cn.gailvlun.gll.presentation.emotion.core.BaseAdapter
import cn.gailvlun.gll.presentation.emotion.core.BaseViewModel
import cn.gailvlun.gll.presentation.emotion.core.RESULT_DELETE
import cn.gailvlun.gll.presentation.emotion.filter.Filter
import cn.gailvlun.gll.net.emotion.FilterEnum


class EmotionDetail2ViewModel : BaseViewModel {

    override var mActivity: BaseActivity
    private val mParentView: View
    val commentTextObservable = ObservableField<String>()
    val isCommentHeaderVisibleObservable = ObservableBoolean()
    val isSendObservable = ObservableBoolean(false)

    constructor(activity: BaseActivity, adapter: BaseAdapter<Any>) : super(activity, adapter) {
        mActivity = activity
        mParentView = layoutInflater.inflate(R.layout.activity_emotion_detail2, null)
        initPopWindow(mParentView)
    }


    fun jump2Profile(emotion: Emotion) {
        super.baseJump2Profile(emotion.owner)
    }

    fun jump2Profile(whichProfile: Profile) {
        super.baseJump2Profile(whichProfile)
    }








    fun showOperateEmotionWindow(view: View, emotion: Emotion) {
        super.baseShowOperateEmotionWindow(mParentView, emotion)
    }

    fun showFunction(anchor: View, emotion: Emotion) {
        super.baseShowFunction(anchor, emotion)
    }

    override fun deleteEmotionCallback(emotion: Emotion) {
        super.deleteEmotionCallback(emotion)
        mActivity.setResult(RESULT_DELETE)
        mActivity.finish()
    }

    override fun heartEmotionCallback(heart: Heart) {
        listener?.onHeart()
    }

    interface OnHeartListener {
        fun onHeart()
    }

    private var listener: OnHeartListener? = null
    fun setOnHeartListener(listener: OnHeartListener) {
        this.listener = listener
    }

    fun onFilter(filter: Filter) {
        when (filter.filterEnum) {
            FilterEnum.ALL -> {
            }
            FilterEnum.N -> {
            }
            FilterEnum.P -> {
            }
            FilterEnum.X -> {
            }
            FilterEnum.CANCEL -> {
            }
        }
    }
}